package com.mnb.base.service.impl;

import com.mnb.base.entity.StRsvrfsrB;
import com.mnb.common.utils.R;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.mnb.base.mapper.StRsvrfsrBMapper;
import com.mnb.base.entity.StRsvrfsrB;
import com.mnb.base.service.StRsvrfsrBService;

import java.util.List;

@Service
public class StRsvrfsrBServiceImpl implements StRsvrfsrBService{

    @Resource
    private StRsvrfsrBMapper stRsvrfsrBMapper;


    @Override
    public int deleteByPrimaryKey(String stcd, String bgmd) {
        return stRsvrfsrBMapper.deleteByPrimaryKey(stcd,bgmd);
    }

    @Override
    public R getList(StRsvrfsrB stRsvrfsrB) {
        List<StRsvrfsrB> list =  stRsvrfsrBMapper.getList(stRsvrfsrB);
        return R.ok(list);
    }

    @Override
    public R insert(StRsvrfsrB stRsvrfsrB) {
        StRsvrfsrB count = stRsvrfsrBMapper.selectByPrimaryKey(stRsvrfsrB.getStcd(), stRsvrfsrB.getBgmd());
        if(count != null){
            return R.fail("该数据已存在");
        }
        stRsvrfsrBMapper.insert(stRsvrfsrB);
        return R.ok();
    }

    @Override
    public R udpate(StRsvrfsrB stRsvrfsrB) {
        stRsvrfsrBMapper.updateByPrimaryKey(stRsvrfsrB);
        return R.ok();
    }

}
